from core.support import set_cutscene
from core.item import Item
from core.action import Action
import random

class Nacho(Item):
    def __init__(self):
        Item.__init__(self, "nachos")    # do basic initialization for every item
        self.has_nachos = True
        self.nacho_count = 0        
        # build list of actions
        self.add_action(EatNachos)
    
    def get_description(self):
            return "Eat crispy crunchy nachos"

# define actions for this item

class EatNachos(Action):
    def __init__(self):
        Action.__init__(self, "eat_nachos")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Crispy crunchy nachos"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"
    
    # only works in basement. add cutscene
    def do_action(self,game,room,request):
        if self.item.has_nachos:
            if room.get_id() == 'cornwalls':
                if room.player_hungry:
                    set_cutscene("You bite into cripsy crunchy nachos and yearn for some hot salsa and cheesy dip")
                    self.item.has_nachos = False
                    self.item.nacho_count = self.item.nacho_count + 1
                    if self.item.nacho_count == 3:
                        room.lock_rusty = False
            else:
                set_cutscene("You squeeze the ___ and a jet of ___ streams on to the floor.  There is a small pool of ___ on the floor.")
                self.item.has_nachos = False
        else:
            set_cutscene("Your stomach growls. You are low on stamina. YOU NEED NACHOS !!")
        return